scoreboard players add @s rmr.entity.timer 1

# hell skill
function rmr:entity/cycle_tick {cycle_time:5}
execute if score @s rmr.entity.rotten_pillager_captain.hell_skill_counter matches 1.. if score @s rmr.entity.cycle_tick matches 0 run function rmr:entity/rotten_pillager_captain/_hell_skill
execute if score @s rmr.entity.rotten_pillager_captain.hell_skill_counter matches 1.. run return 0
execute unless score @s rmr.entity.rotten_pillager_captain.hell_skill_counter matches 1.. run data modify entity @s Invulnerable set value false
# end

# its no longer change stage particle, but im lazy.
# change stage particle and fall protection
function rmr:entity/cycle_tick {cycle_time:4}
execute if score @s rmr.entity.cycle_tick matches 0 run effect give @s slow_falling
execute unless score @s rmr.entity.cycle_tick matches 0 run effect clear @s slow_falling
execute if score @s rmr.entity.rotten_pillager_captain.change_state_effect_time matches 1.. anchored eyes positioned ^ ^ ^-0.5 run particle dust{scale:1, color:[255, 0, 0]} ~ ~ ~ 0.2 0.2 0.2 0.2 10
execute if score @s rmr.entity.rotten_pillager_captain.change_state_effect_time matches 1.. run scoreboard players remove @s rmr.entity.rotten_pillager_captain.change_state_effect_time 1
# end

# change stage
scoreboard objectives add rmr.local.health dummy
execute store result score @s rmr.local.health run data get entity @s Health
execute unless score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 1 if score @s rmr.local.health matches ..40 run function rmr:entity/rotten_pillager_captain/change_stage
execute unless score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 1 if score @s rmr.local.health matches ..40 run scoreboard players set @s rmr.entity.rotten_pillager_captain.stage 2
execute unless score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 0 if score @s rmr.local.health matches ..70 run function rmr:entity/rotten_pillager_captain/change_stage
execute unless score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 0 if score @s rmr.local.health matches ..70 run scoreboard players set @s rmr.entity.rotten_pillager_captain.stage 1

execute if score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 3 if score @s rmr.local.health matches ..40 run function rmr:entity/rotten_pillager_captain/change_stage
execute if score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 3 if score @s rmr.local.health matches ..40 run scoreboard players set @s rmr.entity.rotten_pillager_captain.stage 4
execute if score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 2 if score @s rmr.local.health matches ..90 run function rmr:entity/rotten_pillager_captain/change_stage
execute if score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 2 if score @s rmr.local.health matches ..90 run scoreboard players set @s rmr.entity.rotten_pillager_captain.stage 3
execute if score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 1 if score @s rmr.local.health matches ..130 run function rmr:entity/rotten_pillager_captain/change_stage
execute if score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 1 if score @s rmr.local.health matches ..130 run scoreboard players set @s rmr.entity.rotten_pillager_captain.stage 2
execute if score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 0 if score @s rmr.local.health matches ..170 run function rmr:entity/rotten_pillager_captain/change_stage
execute if score # rmr.entity.hell_mode matches 1 if score @s rmr.entity.rotten_pillager_captain.stage matches 0 if score @s rmr.local.health matches ..170 run scoreboard players set @s rmr.entity.rotten_pillager_captain.stage 1
scoreboard objectives remove rmr.local.health
# end

# regular dash
function rmr:entity/cycle_tick {cycle_time:120}
execute if score @s rmr.entity.cycle_tick matches 75 run function rmr:entity/rotten_pillager_captain/dash

#throw axes
function rmr:entity/cycle_tick {cycle_time:60}
execute if score @s rmr.entity.rotten_pillager_captain.stage matches 1.. if score @s rmr.entity.cycle_tick matches 0 run function rmr:entity/rotten_pillager_captain/throw_at_player
execute if score @s rmr.entity.rotten_pillager_captain.stage matches 2.. if score @s rmr.entity.cycle_tick matches 30 run function rmr:entity/rotten_pillager_captain/throw_at_player
#end

